package System.SystemFacade;

import patterns.decorator.BasicLogger;
import patterns.decorator.SeverityLogger;
import patterns.decorator.SystemLogger;
import patterns.decorator.TimestampLogger;

public class SystemFacade {
    private SystemLogger logger;

    public SystemFacade() {
        // 创建装饰过的日志器
        SystemLogger basicLogger = new BasicLogger();
        SystemLogger timestampLogger = new TimestampLogger(basicLogger);
        this.logger = new SeverityLogger(timestampLogger);
    }

    public void logInfo(String message) {
        logger.log(message);
    }

    public void logError(String message) {
        if (logger instanceof SeverityLogger) {
            ((SeverityLogger) logger).logError(message);
        } else {
            logger.log("[ERROR] " + message);
        }
    }

    public void backupSystem() {
        logInfo("开始系统备份...");
        // 备份逻辑...
        logInfo("系统备份完成");
    }

    public void checkSystemHealth() {
        logInfo("开始系统健康检查...");
        // 检查逻辑...
        logInfo("系统健康检查完成");
    }
}